DEBUG_LINE_LENGTH
DEBUG_LINE_LENGTH = 4096
Database independent query interface
$db_provider : string
factory(string $db_dsnw, string $db_dsnr = '', bool $pconn = false) : \rcube_db
Factory, returns driver-specific instance of the class
string | $db_dsnw | DSN for read/write operations |
string | $db_dsnr | Optional DSN for read only operations |
bool | $pconn | Enables persistent connections |
Object instance
insert_or_update(string $table, array $keys, array $columns, array $values) : \PDOStatement|bool
INSERT ... ON DUPLICATE KEY UPDATE (or equivalent).
When not supported by the engine we do UPDATE and INSERT.
string | $table | Table name (should be already passed via table_name() with quoting) |
array | $keys | Hash array (column => value) of the unique constraint |
array | $columns | List of columns to update |
array | $values | List of values to update (number of elements should be the same as in $columns) |
Query handle or False on error
insert_id(string $table = null) : mixed
Get last inserted record ID
string | $table | Table name (to find the incremented sequence) |
ID or false on failure
None found |
fetch_assoc(mixed $result = null) : mixed
Get an associative array for one row If no query handle is specified, the last query will be taken as reference
mixed | $result | Optional query handle |
Array with col values or false on failure
None found |
fetch_array(mixed $result = null) : mixed
Get an index array for one row If no query handle is specified, the last query will be taken as reference
mixed | $result | Optional query handle |
Array with col values or false on failure
None found |
list_tables() : array
Returns list of tables in a database
List of all tables of the current database
None found |
list_cols(string $table) : array
Returns list of columns in database table
string | $table | Table name |
List of table cols
None found |
startTransaction() : bool
Start transaction
True on success, False on failure
None found |
endTransaction() : bool
Commit transaction
True on success, False on failure
None found |
rollbackTransaction() : bool
Rollback transaction
True on success, False on failure
None found |
reset() : mixed
Release resources related to the last query result.
When we know we don't need to access the last query result we can destroy it and release memory. Useful especially if the query returned big chunk of data.
None found |
None found |
quote(mixed $input, string $type = null) : string
Formats input so it can be safely used in a query PDO_OCI does not implement quote() method
mixed | $input | Value to quote |
string | $type | Type of data (integer, bool, ident) |
Quoted/converted string for use in query
None found |
escape(string $str) : string
Escapes a string so it can be safely used in a query
string | $str | A string to escape |
Escaped string for use in a query
None found |
quoteIdentifier(string $str) : string
Quotes a string so it can be safely used as a table or column name
string | $str | Value to quote |
Quoted string for use in query
None found |
escapeSimple(string $str) : string
Escapes a string so it can be safely used in a query
string | $str | A string to escape |
Escaped string for use in a query
None found |
quote_identifier(string $str) : string
Quotes a string so it can be safely used as a table or column name
string | $str | Value to quote |
Quoted string for use in query
None found |
param(mixed $value, string $type = null) : mixed
Create query parameter object
mixed | $value | Parameter value |
string | $type | Parameter type (one of rcube_db::TYPE_* constants) |
None found |
now(int $interval) : string
Return SQL function for current time and date
int | $interval | Optional interval (in seconds) to add/subtract |
SQL function to use in query
None found |
array2list(array $arr, string $type = null) : string
Return list of elements for use with SQL's IN clause
array | $arr | Input array |
string | $type | Type of data (integer, bool, ident) |
Comma-separated list of quoted values for use in query
None found |
unixtimestamp(string $field) : string
Return SQL statement to convert a field value into a unix timestamp
string | $field | Field name |
SQL statement to use in query
None found |
fromunixtime(int $timestamp) : string
Return SQL statement to convert from a unix timestamp
int | $timestamp | Unix timestamp |
Date string in db-specific format
None found |
ilike(string $column, string $value) : string
Return SQL statement for case insensitive LIKE
string | $column | Field name |
string | $value | Search value |
SQL statement to use in query
None found |
concat() : string
Abstract SQL statement for value concatenation
SQL statement to be used in query
None found |
encode(mixed $input, bool $serialized = false) : mixed
Encodes non-UTF-8 characters in string/array/object (recursive)
mixed | $input | Data to fix |
bool | $serialized | Enable serialization |
Properly UTF-8 encoded data
None found |
decode(mixed $input, bool $serialized = false) : mixed
Decodes encoded UTF-8 string/object/array (recursive)
mixed | $input | Input data |
bool | $serialized | Enable serialization |
Decoded data
None found |
table_name(string $table, bool $quoted = false) : string
Return correct name for a specific database table
string | $table | Table name |
bool | $quoted | Quote table identifier |
Translated table name
None found |
set_option(string $name, mixed $value) : mixed
Set class option value
string | $name | Option name |
mixed | $value | Option value |
None found |
set_table_dsn(string $table, string $mode) : mixed
Set DSN connection to be used for the given table
string | $table | Table name |
string | $mode | DSN connection ('r' or 'w') to be used |
None found |
parse_dsn(mixed $dsn) : array
MDB2 DSN string parser
mixed | $dsn |
DSN parameters
None found |
exec_script(string $sql) : bool
Execute the given SQL script
string | $sql | SQL queries to execute |
True on success, False on error
None found |
dsn_connect(array $dsn, string $mode) : mixed
Connect to specific database
array | $dsn | DSN for DB connections |
string | $mode | Connection mode (r|w) |
None found |
conn_create(mixed $dsn) : mixed
Create connection instance
mixed | $dsn |
None found |
conn_prepare(array $dsn) : mixed
Driver-specific preparation of database connection
array | $dsn | DSN for DB connections |
None found |
conn_configure(array $dsn, \PDO $dbh) : mixed
Driver-specific configuration of database connection
array | $dsn | DSN for DB connections |
\PDO | $dbh | Connection handler |
None found |
dsn_select(mixed $query) : mixed
Analyze the given SQL statement and select the appropriate connection to use
mixed | $query |
None found |
debug(string $query) : mixed
Writes debug information/query to 'sql' log file
string | $query | SQL query |
None found |
_query(string $query, int $offset, int $numrows, array $params) : \PDOStatement|bool
Execute a SQL query with limits
string | $query | SQL query to execute |
int | $offset | Offset for LIMIT statement |
int | $numrows | Number of rows for LIMIT statement |
array | $params | Values to be inserted in query |
Query handle or False on error
None found |
query_execute(mixed $query) : mixed
Query execution
mixed | $query |
None found |
query_parse(string $query) : string
Parse SQL query and replace identifier quoting
string | $query | SQL query |
SQL query
None found |
handle_error(mixed $query, mixed $result = null) : mixed
Helper method to handle DB errors.
This by default logs the error but could be overridden by a driver implementation
mixed | $query | Query that triggered the error |
mixed | $result |
Result to be stored and returned
None found |
_fetch_row(mixed $result, int $mode) : array|false
Get col values for a result row
mixed | $result | Optional query handle |
int | $mode | Fetch mode identifier |
Array with col values or false on failure
None found |
set_limit(string $query, int $limit, int $offset) : string
Adds TOP (LIMIT,OFFSET) clause to the query
string | $query | SQL query |
int | $limit | Number of rows |
int | $offset | Offset |
SQL query
None found |
dsn_string(array $dsn) : string
Returns PDO DSN string from DSN array
array | $dsn | DSN parameters |
DSN string
None found |
dsn_options(mixed $dsn) : array
Returns connection options from DSN array
mixed | $dsn | DSN parameters |
Connection options
None found |
fix_table_names(mixed $sql) : mixed
Parse SQL file and fix table names according to table prefix
mixed | $sql |
None found |
fix_table_names_callback(mixed $matches) : mixed
Preg_replace callback for fix_table_names()
mixed | $matches |
None found |
sequence_name(string $table) : string
Return correct name for a specific database sequence
string | $table | Table name |
Translated sequence name
None found |
fix_table_names_seq_callback(mixed $matches) : mixed
Preg_replace callback for fix_table_names()
mixed | $matches |
None found |